package com.jlnk.stockdemo.bean;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class FutureListResponse {

    @SerializedName("request_id")
    private String requestId;

    @SerializedName("code")
    private int code;

    @SerializedName("data")
    private FutureListResponse.Data data;

    @SerializedName("msg")
    private String msg;

    public String getRequestId() {
        return requestId;
    }

    public int getCode() {
        return code;
    }

    public FutureListResponse.Data getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public static class Data {
        @SerializedName("fields")
        private List<String> fields;

        @SerializedName("items")
        private List<List<String>> items;

        @SerializedName("has_more")
        private boolean hasMore;

        @SerializedName("count")
        private int count;

        private List<Future> futureList;

        public List<String> getFields() {
            return fields;
        }

        public List<List<String>> getItems() {
            return items;
        }

        public boolean isHasMore() {
            return hasMore;
        }

        public int getCount() {
            return count;
        }

        public List<Future> getFutureList() {
            futureList = new ArrayList<>();
            int tsCodeIndex, symbolIndex, nameIndex, quote_unitIndex, d_mode_descIndex, last_ddateIndex;
            tsCodeIndex = symbolIndex = nameIndex = quote_unitIndex = d_mode_descIndex = last_ddateIndex =0;
            for (int i = 0; i < fields.size(); i++) {
                switch (fields.get(i)) {
                    case "ts_code" :
                        tsCodeIndex = i;
                        break;
                    case "symbol" :
                        symbolIndex = i;
                        break;
                    case "name" :
                        nameIndex = i;
                        break;
                    case "quote_unit" :
                        quote_unitIndex = i;
                        break;
                    case "d_mode_desc" :
                        d_mode_descIndex = i;
                        break;
                    case "last_ddate" :
                        last_ddateIndex = i;
                        break;
                }
            }
            for (int j = 0; j < items.size(); j++) {
                Future future = new Future();
                future.setTsCode(items.get(j).get(tsCodeIndex));
                future.setSymbol(items.get(j).get(symbolIndex));
                future.setName(items.get(j).get(nameIndex));
                future.setQuote_unit(items.get(j).get(quote_unitIndex));
                future.setD_mode_desc(items.get(j).get(d_mode_descIndex));
                future.setLast_ddate(items.get(j).get(last_ddateIndex));
                futureList.add(future);
            }
            return futureList;
        }

        public static class Future {
            private String tsCode;
            private String symbol;
            private String name;
            private String quote_unit;
            private String d_mode_desc;
            private String last_ddate;

            public String getTsCode() {
                return tsCode;
            }

            public void setTsCode(String tsCode) {
                this.tsCode = tsCode;
            }

            public String getSymbol() {
                return symbol;
            }

            public void setSymbol(String symbol) {
                this.symbol = symbol;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getQuote_unit() {
                return quote_unit;
            }

            public void setQuote_unit(String quote_unit) {
                this.quote_unit = quote_unit;
            }

            public String getD_mode_desc() {
                return d_mode_desc;
            }

            public void setD_mode_desc(String d_mode_desc) {
                this.d_mode_desc = d_mode_desc;
            }

            public String getLast_ddate() {
                return last_ddate;
            }

            public void setLast_ddate(String last_ddate) {
                this.last_ddate = last_ddate;
            }
        }
    }
}
